<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var str = 'abcdacbabcbababcbabcabd'

        // 将字符串转成数组
        var arr = str.split('');
        
        var res = arr.reduce(function(pic,cur){
            if(cur in pic){
                pic[cur] += 1
            }else{
                pic[cur] = 1
            }
            return pic
        },{})

    </script>
</body>
</html>